package zxj.spay.util;

import java.security.MessageDigest;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;

public class SHA2Util {

	/**
	 * 进行SHA256的算法摘要
	 * @param text 需要摘要的文本
	 * @return 摘要后进行编码的文本
	 */
	public static String sha256(String text){
		MessageDigest digest = DigestUtils.getSha256Digest();
		byte[] digest2 = digest.digest(text.getBytes());
		String encodeBase64String = Base64.encodeBase64String(digest2);
		return encodeBase64String;
	}
	
	
}
